<script lang="ts" setup>
import BaseButton from "@/components/BaseButton/index.vue";
import BaseUpDown from "@/components/BaseUpDown/index.vue";
import BaseCollapse from "@/components/BaseCollapse/index.vue";
import useSearch from "@/hooks/useSearch";
import useData from "./hooks/useData";
import { useUserStore } from "@/stores/modules/user";
import WebLoginTimeout from "./components/WebLoginTimeout/index.vue";
import SysConfigTime from "./components/SysConfigTime/index.vue";
import ManageAddrCfg from "./components/ManageAddrCfg/index.vue";
import SystemInstruct from "./components/SystemInstruct/index.vue";
import SysUpdate from "./components/SysUpdate/index.vue";
import Syslog from "./components/Syslog/index.vue";
import Licence from "./components/Licence/index.vue";
import PasswordPolicy from "./components/PasswordPolicy/index.vue";
import ServiceBox from "./components/ServiceBox/index.vue";

const { pageData, roleMap } = useData();
import { deleteData, getDataByPage } from "@/api/modules/system/account";
import UpdateForm from "./components/UpdateForm/index.vue";
import UpdateFormPassword from "./components/UpdateFormPassword/index.vue";

const userStore = useUserStore();
const username = computed(() => userStore.userInfo.name);
const { tableData, loadData, formData, reloadData } = useSearch({
  defaultData: {
    sysTimeType: 1
  },
  responseKey: {
    list: "result.data",
    total: "result.total"
  }
});

function loadDataCb() {
  loadData({
    api: getDataByPage,
    sendData: {
      pageNum: formData.pageNum - 1,
      pageSize: formData.pageSize
    }
  });
}

loadDataCb();

function reloadDataCb() {
  reloadData();
  loadData({
    api: getDataByPage,
    sendData: {
      pageNum: formData.pageNum - 1,
      pageSize: formData.pageSize
    }
  });
}

loadDataCb();

/**删除*/
import useDelete from "@/hooks/useDelete";
import { computed } from "vue";

const { deleteHandler, idList } = useDelete();

async function deleteCb(id) {
  await deleteHandler({
    api: deleteData,
    multiple: false,
    sendData: {
      id: [id]
    },
    hideMessageBox: false
  });
  loadDataCb();
}

function selectCb(data) {
  console.log(data);
  idList.value = data.rowList.map(item => item.userId);
}
</script>

<template>
  <BaseUpDown>
    <el-row :gutter="10">
      <el-col :span="7">
        <WebLoginTimeout />
      </el-col>
      <el-col :span="7">
        <SysConfigTime/>
      </el-col>
      <el-col :span="10">
       <ManageAddrCfg/>
      </el-col>
    </el-row>
    <el-row class="mg-t-sm" :gutter="10">
      <el-col :span="7">
        <SysUpdate />
      </el-col>
      <el-col :span="8" >
        <Syslog/>
      </el-col>
<!--      <el-col :span="8">-->
<!--        <PasswordPolicy />-->
<!--      </el-col>-->
      <el-col :span="4">
       <Licence/>
      </el-col>
      <el-col :span="5">
        <SystemInstruct></SystemInstruct>
      </el-col>

    </el-row>
    <el-row class="mg-t-sm" :gutter="10">
      <el-col :span="7">
        <PasswordPolicy />
      </el-col>
    </el-row>
  </BaseUpDown>
</template>
